import Vue from 'vue'
import Components from '@/components'
import 'normalize.css/normalize.css' // A modern alternative to CSS resets
import * as filters from './filters'
import checkPermission from './mixin/checkPermission'

import ElementUI from 'element-ui'
import 'element-ui/lib/theme-chalk/index.css'
// import locale from 'element-ui/lib/locale/lang/en' // lang i18n

import '@/styles/index.scss' // global css

import App from './App'
import store from './store'
import router from './router'

import '@/icons' // icon
import '@/permission' // permission control  路由守卫

import * as directives from '@/directives' // 导入自定义指令

import i18n from './lang'

// 将所有的指令，挂载到Vue实例周昂    Object.keys()  获取对象中所有的key 返回一个数组
Object.keys(directives).forEach(obj => {
  Vue.directive(obj, directives[obj])
})

Object.keys(filters).forEach(obj => {
  Vue.filter(obj, filters[obj])
})

Vue.use(Components)
// set ElementUI lang to EN
// Vue.use(ElementUI, { locale })
// 如果想要中文版 element-ui，按如下方式声明
// Vue.use(ElementUI)

Vue.use(ElementUI, {
  i18n: (key, value) => i18n.t(key)
})

// 全局混入检查对象
Vue.mixin(checkPermission) // 表示所有的组件都有了一个检查的方法

Vue.config.productionTip = false

new Vue({
  el: '#app',
  router,
  store,
  i18n,
  render: h => h(App)
})
